package reflect;

import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入类名:");
        String className = sc.nextLine();
        Class cls = Class.forName(className);


        Object obj = cls.newInstance();//只能使用无参构造器实例化
        System.out.println(obj);
    }

}
